<?php
defined('_JEXEC') or die('Restricted access');
require_once(JPATH_COMPONENT.DS.'data'.DS.'DAOPOICategory.php');
require_once(JPATH_COMPONENT.DS.'dominio'.DS.'DTOFactory.php');

class JDAOPOICategory implements DAOPOICategory{
	
	
	private function singleObjectQuery($query){
		$db =& JFactory::getDBO();
		$db->setQuery( $query );
		$row = $db->loadObject();
		if ($db->getErrorNum()) {
			echo $db->stderr();
			return false;
		}
		return $row;
	}
	private function multiObjectQuery($query){
		$db =& JFactory::getDBO();
		$db->setQuery( $query );
		$rows = $db->loadObjectList();
		if ($db->getErrorNum()) {
			echo $db->stderr();
			return false;
		}
		return $rows;
	}
	/* (non-PHPdoc)
	 * @see DAOPOICategory::getPOICategory()
	 */
	public function getPOICategory($id) {
		$row=$this->singleObjectQuery("SELECT * FROM #__sr_poicategories WHERE id=".$id);
		return DTOFactory::getInstance()->getDTOPOICategory($row);
	}

	public function getPOICategories(){
		$rows=$this->multiObjectQuery("SELECT * FROM #__sr_poicategories");
		return DTOFactory::getInstance()->getDTOPOICategories($rows);
	}
	
}

?>